package org.example.javafxdemo;

/**
 * @Author 56465
 * @Create 2024/7/29 15:07
 */
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

import java.net.URL;

public class BootstrapInJavaFX extends Application {

    @Override
    public void start(Stage primaryStage) {
        WebView webView = new WebView();
        String html_code = """
                <html><head>
                <link href="/static/css/bootstrap.min.css" rel="stylesheet">
                </head><body>
                <div class='container mt-5'>
                  <h1>Hello, Bootstrap in JavaFX!</h1>
                  <p class='lead'>This is a simple example of embedding Bootstrap in a JavaFX WebView.</p>
                </div>
                </body>
                </html>
                """;


        webView.getEngine().loadContent(html_code);

        StackPane root = new StackPane();
        root.getChildren().add(webView);

        Scene scene = new Scene(root, 800, 600);

        primaryStage.setTitle("Bootstrap in JavaFX");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}